<template>
  <div>
    <van-sidebar v-model="activeKey">
      <div v-for="(item, index) in List" :key="index">
        <van-sidebar-item :title="item.label" />
      </div>
    </van-sidebar>
  </div>
</template>

<script>
// 接口路径有问题
import service from "../../utils/service";

// json-server模拟接口应用
import data from "../../mock/data.json";

export default {
  data() {
    return {
      // activeId: 1,
      // activeIndex: 0,
      activeKey: 0,
      List: [],
    };
  },
  // 路由接口(路径问题)
  // mounted() {
  //   service({
  //     url: "/city/city.json",
  //     method: "get",
  //   }).then((res) => {
  //     res.data.data.forEach((element) => {
  //       this.List.push(element);
  //     });
  //   });
  // },
  mounted() {
    console.log(data);
    this.List = data;
  },
};
</script>

<style>
</style>